<?php
	// ustaw domyślne opcje
	if (isset($this->options) || !is_array($this->options)) {
		switch($this->type) {
			default:
			case 'add':
				$this->options = array(
					'back','reset','save','save_back','save_edit'
				);
				break;

			case 'edit':
				$this->options = array(
					'back','reset','save','save_back','save_edit'
				);
				break;

			case 'delete':
				$this->options = array(
					'back','save_back'
				);
				break;
		}
	}
?>

<div class="options-wrapper">
	<ul class="options-holder left">
		<li class="option"><h3 class="title"><?php print $this->title ?></h3></li>
		
		<li class="option separator"></li>

		<?php if ($this->type == 'edit'):?>
		<li class="option nondecoration">
			<a class="action delete"
			   title="Usuń rekord"
			   href="<?php print $this->url(array('action' => 'delete'))?>">Usuń</a></li>
		<?php endif;?>

	</ul>

	<ul class="options-holder right">
		<?php if (in_array('back', $this->options)):?>
		<li class="option">
			<a class="action back"
			   title="Powrót do spisu rekordów"
			   href="<?php print $this->url(array('action' => 'list'))?>">Powrót</a></li>
	   <?php endif;?>

		<?php if (in_array('reset', $this->options)):?>
		<li class="option">
			<a id="kx_form_new"
			   class="action reset" 
			   href="<?php print $this->url(array())?>">Zacznij od nowa</a></li>
		<?php endif;?>
		
		<?php if (in_array('save', $this->options)):?>
		<li class="option separator"></li>

		<li class="option">
			<a id="kx_form_save_next"
			   class="action add"
			   onclick="document.formreturn false;"
			   href="<?php print $this->baseUrl()?>#save_next">Zapisz i dodaj następy</a></li>
		<?php endif;?>
	
		<?php if (in_array('save_back', $this->options)):?>
			<?php if ($this->type == 'delete'):?>
			<li class="option">
				<a id="kx_form_save_exit"
				   class="action delete" 
				   href="<?php print $this->baseUrl()?>#save_exit">Usuń rekord</a></li>
			<?php else:?>
			<li class="option">
				<a id="kx_form_save_exit"
				   class="action save" 
				   href="<?php print $this->baseUrl()?>#save_exit">Zapisz i zakończ</a></li>
			<?php endif;?>
				
		<?php endif;?>
		
		<?php if (in_array('save_edit', $this->options)):?>
		<li class="option separator"></li>

		<li class="option">
			<a id="kx_form_save_edit"
			   class="action save"
			   onclick="document.formreturn false;"
			   href="<?php print $this->baseUrl()?>#save_edit">Zapisz i edytuj</a></li>
		<?php endif;?>
	</ul>
	<script type="text/javascript"><!--
		// element akcji
		var actionElement = document.createElement('input');
		actionElement.type = 'hidden';
		actionElement.name = '__kx_action';

		/*
		document.getElementById('kx_form_new').onclick = function() {
			if (document.forms[0] !== undefined) {
				actionElement.value = 'new';
				$('#kx_tab_form').append(actionElement).submit();
			}
			return false;
		};
		*/
		document.getElementById('kx_form_save_next').onclick = function() {
			if (document.forms[0] !== undefined) {
				actionElement.value = 'next';
				$('#kx_tab_form').append(actionElement).submit();
			}
			return false;
		};
		document.getElementById('kx_form_save_exit').onclick = function() {
			if (document.forms[0] !== undefined) {
				actionElement.value = 'exit';
				$('#kx_tab_form').append(actionElement).submit();
			}
			return false;
		};
		document.getElementById('kx_form_save_edit').onclick = function() {
			if (document.forms[0] !== undefined) {
				actionElement.value = 'save';
				$('#kx_tab_form').append(actionElement).submit();
			}
			return false;
		};
	--></script>
</div>